- page        ||= index_branch
- children      = @pages_by_parent[page.id]
- siblings      = @pages_by_parent[page.parent_id]
- has_children  = children.present?
- has_siblings  = siblings.size > 1
- branch_open   = (session[:cms_page_tree] || []).member?(page.id.to_s) || page.root?
- category_view = params[:categories].present?

%li{id: dom_id(page), data: {id: page.id}}
  .row

    .col-md-6.item
      - unless category_view
        .item-controls
          - if has_siblings
            .dragger.d-none.d-md-block
              %i.fas.fa-bars

          - if has_children && !page.root?
            - status = branch_open ? "open" : ""
            - url = toggle_branch_comfy_admin_cms_site_page_path(@site, page)
            = link_to url, remote: true, title: t(".toggle"), class: "toggle #{status}" do
              %i.fas.fa-plus-square.expand
              %i.fas.fa-minus-square.collapse

      .item-content
        .item-title
          - published_css_class = page.is_published? ? "published" : "draft"
          = link_to page.label, edit_comfy_admin_cms_site_page_path(@site, page), class: published_css_class
        .item-meta
          = link_to page.url, page.url, target: "_blank"

    .col-md-2.item-categories.d-flex.align-items-center
      = render "comfy/admin/cms/categories/categories", object: page

    .col-md-4.d-flex.align-items-center.justify-content-md-end
      .btn-group.btn-group-sm
        = link_to t(".add_child_page"), new_comfy_admin_cms_site_page_path(@site, parent_id: page.id), class: "btn btn-outline-secondary"
        = link_to t(".edit"), edit_comfy_admin_cms_site_page_path(@site, page), class: "btn btn-outline-secondary"
        = link_to t(".delete"), comfy_admin_cms_site_page_path(@site, page), method: :delete, data: {confirm: t('.are_you_sure')}, class: "btn btn-danger"

  - if !category_view && has_children && branch_open
    %ul.list.children.sortable.pl-md-3
      = render partial: "index_branch", collection: children
